/*
 * sokobanSprite.java
 *
 * Created on 29 de diciembre de 2006, 02:59 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package hello;


import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
/**
 * @author anfeques
 */

public class sokobanSprite extends Sprite{
    private int delta;
    private int posx=0;
    private int posy=0;
    private int score;                  // number of steps has given by soko  
    private int lastposy;
    private int lastposx;
    
    /**
     * @param imag Imagen apra aplicarle al sprite
     * @param widthFrame ancho de cada frame debe ser multiplo de el ancho de la imagen
     * @param heightFame alto de cada frame debe ser multiplo de el alto de la imagen
     */
    public sokobanSprite(Image imag, int widthFrame, int heightFame) {        
        super(imag, widthFrame, heightFame);
        this.defineReferencePixel(widthFrame/2,heightFame/2);
        this.score = 0;        
    }
    
    public void setPosicion(int x,int y){
        this.setPosx(x);
        this.setPosy(y);
        this.setPosition(x, y);
    }
    
    public int getWidthFrame(){
        return this.getWidth();
    }
    
    public int getAltoFrame(){
        return this.getHeight();
    }
    
    public void moverVertical(int dir){        
        this.setLastPosition();
        posy+=dir*delta;
        this.setPosition(posx, posy);
        if(dir==1)
            this.setFrame(0);
        else
            this.setFrame(2); 
    }
    
    public void moverHorizontal(int dir){
        this.setLastPosition();
        posx+=dir*delta;
        this.setPosition(posx, posy);
        if(dir==1)
            this.setFrame(1);
        else
            this.setFrame(3);
    }
    
    public void incrementarPasos(){
        this.score++;
    }

    public void DecrementarPasos(){
        this.score--;
    }
    
    //Metodos SET AND GET
    public int getDelta() {
        return delta;
    }
    
    public void setDelta(int delta) {
        this.delta = delta;
    }
    
    public int getPosx() {
        return posx;
    }
    
    public void setPosx(int posx) {
        this.posx = posx;
    }
    
    public int getPosy() {
        return posy;
    }
    
    public void setPosy(int posy) {
        this.posy = posy;
    }
    
    public String getPasos() {        
        return String.valueOf(this.score);
    }
    
    public void setPasos(int pasos) {
        this.score = pasos;
    }    
    
    public int getLastPosy() {
        return this.lastposy;    }
    
    public int getLastPosx() {
        return this.lastposx;
    }

    private void setLastPosx() {
        this.lastposx = this.posx;
    }

    private void setLastPosy() {
       this.lastposy =this.posy;
    }

    private void setLastPosition() {
        setLastPosx();
        setLastPosy();
    }
    
    

}

